package com.kyivmohyla.kma2.dao.mapper;

import com.kyivmohyla.kma2.model.Equipment;
import org.springframework.jdbc.core.ResultSetExtractor;

import java.sql.ResultSet;
import java.sql.SQLException;

class EquipmentResultSetExtractor implements ResultSetExtractor<Equipment> {

    @Override
    public Equipment extractData(ResultSet resultSet) throws SQLException {
        Equipment equipment = new Equipment();
        try {
            equipment.setEquipmentId(resultSet.getInt("equipment_id"));
            equipment.setName(resultSet.getString("name"));
            equipment.setIsParent(resultSet.getInt("is_parent"));
            equipment.setParentId(resultSet.getInt("parent_id"));
            equipment.setDescription(resultSet.getString("description"));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return equipment;
    }

}